/**
 * 会诊详情
 */
import request, { IResposeItem } from "@/configs/request"

interface IBase {
  // id: number | null;
  topic: string | null;
  // goal: string | null;
  // patientId: string | null;
  // patientName: string | null;
  status: number | null;
  statusRes: string | null;
  groupId: number | null;
  groupName: string | null;
  // applierName: string | null;
  // startTime: string | null;
  // deptName: string | null;
  historyCount: number | null;
  consultUsers: Array<IConsultUser> | [];
  cancelReason?: boolean | null;
  cancelReasonRes?: string | null;
  cancelExplain?: string | null;
  remark: string | null;
}

interface IConsultBase extends Record<string, any> {
  id: number | null;
  goal: string | null;
  patientId: string | null;
  patientName: string | null;
  applierName: string | null;
  startTime: string | null;
  deptName: string | null;
  photo: string | null
}
/**
 * 会诊详情医生
 */
export interface IConsultUser extends Record<string, any> {
  consultUserId: number;// 会诊成员ID
  username: string | null;
  hospitalName: string | null;
  titleName: string | null;
  deptName: string | null;
  attendStatus: number;
  attendStatusRes: string | null;
  contactPhone?: number | null;
}

/**
 * 会诊详情数据接口
 */
export interface IConsultDetails extends Record<string, any> {
  id: number | null;
  topic: string | null;
  goal: string | null;
  patientId: string | null;
  patientName: string | null;
  status: number | null;
  statusRes: string | null;
  groupId: number | null;
  groupName: string | null;
  applierName: string | null;
  startTime: string | null;
  deptName: string | null;
  historyCount: number | null;
  consultUsers: Array<IConsultUser> | [];
  cancelReason?: boolean | null;
  cancelReasonRes?: string | null;
  cancelExplain?: string | null;
  remark: string | null;
  consultUserStr: string | null;
}

export interface IConsultUserL extends Record<string, any> {
  username: string | null;
  titleName?: string | null;
  photo?: string | null;
  deptName?: string | null;
  advise?: string | null;
  hospitalName: string | null;
}


export interface IAnnex {
  fileName: string | null;
  fileUrl: string | null;
  tag: number | null;
  tagRes: string | null;
  fileSize: string | null;
  uploadTime: string | null;
  suffix: string | null;
}

export interface IConsultHistory {
  id: number | null;
  description: string | null;
  startTime: string | null;
  endTime: string | null;
  annexList: Array<IAnnex> | [];
}

/**
 * 会诊报告和病患信息数据接口
 */
export interface IConsultReport {
  id: number | null;
  goal: string | null;
  patientId: string | null;
  patientName: string | null;
  patientSex: number | null;
  patientSexRes: string | null;
  patientAge?: number | null;
  patientType?: string | null;
  patientTypeRes?: string | null;
  diagnosis: string | null;
  patientCard?: any | null;
  applierName: string | null;
  startTime: string | null;
  leaderAdvise?: string | null;
  deptName: string | null;
  consultUsers: Array<IConsultUserL> | [];
  consultHistoryList: Array<IConsultHistory> | [];
}




/**
 * 查看会诊详情
 * @param consultId 
 * @returns 
 */
export const consultDetails = async (consultId: number): Promise<IResposeItem<IConsultDetails>> => {
  return request.get(`/cr/crConsult/details/${consultId}`)
}

/**
 * 会诊报告和病患信息
 * @param consultId 
 * @returns 
 */
export const consultReport = async (consultId: number): Promise<IResposeItem<IConsultReport>> => {
  return request.get(`/cr/crConsult/report/${consultId}`)
}

export interface IdelConsultUserPar {
  consultId: number;
  userId: number;
}

/**
 * 删除一个会诊成员
 * @param parmas 
 * @returns 
 */
export const delConsultUser = async (parmas: IdelConsultUserPar): Promise<IResposeItem<any>> => {
  return request.post("/cr/crConsultUser/delete", parmas)
}